/*
 * Copyright (c) 2007 Compl Yue Still, All Rights Reserved.
 */

package hbi.wire.as3.host
{
	import hbi.wire.ProtocolError;
	
	public class ResolvedType
	{
		
		internal var as3Class:Class;
		
		public function ResolvedType(as3Class:Class)
		{
			this.as3Class = as3Class;
		}
		
		[ArrayElementType("String")]
		private var resolvedMethods:Array = new Array();
		
		public function resolveMehtod(methodName:String):void
		{
			var unmangledName:String = methodName;
			var pos:int = methodName.indexOf('#');
			if(pos > 0) unmangledName = methodName.substring(0, pos);
// below just doesn't work, need another way to validate the existance of a 
// method. without validation here, method absence errors are delayed to 
// invocation time
//			if(!(as3Class.prototype[unmangledName] is Function))
//				throw new ProtocolError("Unresolvable method: " + methodName);
			resolvedMethods.push(unmangledName);
		}
		
		public function getResolvedMethod(methodIndex:int):String
		{
			return resolvedMethods[methodIndex];
		}
	}
}
